package com.example.minefieldkeepercloud.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.example.minefieldkeepercloud.R;
import com.example.minefieldkeepercloud.activity.commonpool.PoolDetailAc;
import com.example.minefieldkeepercloud.activity.commonpool.SetPool;
import com.example.minefieldkeepercloud.bean.CommonPoolBean;
import com.king.base.adapter.ViewHolderRecyclerAdapter;
import com.king.base.adapter.holder.ViewHolder;

import java.util.List;

public class CommonPoolAdapter extends ViewHolderRecyclerAdapter<CommonPoolBean.DataBean> {
    private Activity context;

    public CommonPoolAdapter(Activity context, List<CommonPoolBean.DataBean> listData) {
        super(context, listData);
        this.context = context;
    }


    @Override
    public View buildConvertView(LayoutInflater layoutInflater, int viewType) {
        return layoutInflater.inflate(R.layout.adapter_commonpool,null);
    }
    @Override
    public void bindViewDatas(ViewHolder holder, final CommonPoolBean.DataBean bean, final int position) {


        TextView tv=holder.getView(R.id.tv_state);
        if(bean.getState()==0)
        {
            tv.setText("关闭");
            tv.setTextColor(context.getResources().getColor(R.color.red));
        }
        else
        {
            tv.setText("开启");
            tv.setTextColor(context.getResources().getColor(R.color.system_color));
        }

        holder.setText(R.id.tv_name,bean.getTgUserName());
        holder.setText(R.id.tv_pool,bean.getPool());
        holder.setText(R.id.tv_kname,bean.getMinerName());
        holder.setText(R.id.tv_phone,bean.getTgPhone()+"");

        holder.getConvertView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SetPool.start(context,bean.getId()+"");
                context.overridePendingTransition(0, 0);
            }
        });

    }




}
